package cjj.file;

import java.io.*;

/**
 * @author chenjunjie
 * @since 2018-06-04
 */
public class jemeterData {

    public static void main(String[] args) {
        //File file = new File("D://data.txt");

        try {
            StringBuffer sb= new StringBuffer("");
            FileReader reader = new FileReader("d://pass.json");
            BufferedReader br = new BufferedReader(reader);
            String str = null;
            FileOutputStream out = null;
            out = new FileOutputStream(new File("D:\\password.txt"));
            while((str = br.readLine()) != null) {
                String[] strs=str.split(":");

                if(strs[0].equals("\"account\"")){
                    sb.append(strs[1]);
                    out.write(strs[1].getBytes());
                }

                if(strs[0].equals("\"account_type\"")){
                    sb.append(strs[1]+"\n");
                    out.write((strs[1]+"\n").getBytes());
                }

                if(strs[0].equals("\"password\"")){
                    sb.append(strs[1]);
                    out.write((strs[1]).getBytes());
                }
            }

            System.out.println(sb);
            br.close();
            out.close();
            reader.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }


//        FileInputStream inputStream = null;
//        try {
//            inputStream = new FileInputStream(file);
//            int tempbyte;
//
//            while ((tempbyte = inputStream.read())!=-1) {
//                System.out.println(tempbyte);
//            }
//        } catch (FileNotFoundException e) {
//            e.printStackTrace();
//        }
//        catch (IOException e) {
//            e.printStackTrace();
//        }
//
//        //5.关闭输入输出流
//        try {
//            inputStream.close();
//        } catch (IOException e) {
//            e.printStackTrace();
//        }

    }
}
